package com.springboot.redis.mapper;

import com.springboot.redis.bean.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Component;


@Mapper
@CacheConfig
public interface StudentMapper {


    @Insert("insert into student(sno,sname,ssex) values (#{sno},#{sname},#{ssex})")
    int add(Student student);

    @Update("update student set sname = #{name},ssex = #{sex},where sno = #{sno}")
    int update(Student student);

    @Delete("delete from student where sno = #{sno}")
    int deleteBysno(String sno);

    @Select("select * from student where sno = #{sno}")
    @Results(id = "student", value = {
            @Result(property = "sno", column = "sno", javaType = Integer.class),
            @Result(property = "name", column = "sname", javaType = String.class),
            @Result(property = "sex", column = "ssex", javaType = String.class)
    })
    Student queryStudentBySno(Integer sno);
}
